/* 桶排序 */

#include<algorithm>
#include<cstdlib>
#include<iostream>
using namespace std;

struct RandMod100
{
	int operator()(void) {return rand() % 100;}
};

int main(void)
{
	int a[20];

	generate(a, a + 20, RandMod100{});
	for_each(a, a + 20, [](int e) -> void {cout<< e << " ";});
	cout<< endl <<endl;

	int numCount[100]{0};
	for_each(a, a + 20, [&numCount](int e) -> void {numCount[e]++;});
	for (int i = 0; i < 100; i++)
	{
		if (numCount[i] != 0)
		{
			for (int j = 0; j < numCount[i]; j++)
			{
				cout<< i << " ";
			}
		}
	}
	cout<< endl;
}
